- /* sdfupdtc.cpp by K.Tsuru */
- // function ID 3701 DRADIX
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- /*******************************************************
- fname = "e.snc", "log10.snc" or "pi.snc"
- return NO_SNC_DIR : "SNC_DIR" does not exist.
- return SNC_ENOUGH : The constant file has enough length.
- return SNC_UPDATE : The constant file has been updated.
- ********************************************************/
- int UpdateConstantFile(const char* fname,
- SDouble (*pfunc)(const SDouble* c, SDouble (*pf)()),
- SDouble (*pfCalcFunc)(), uint ef){
- char sncFile[SNC_MAX_PATH];
- int exist = ExistSncDirectory(sncFile);// If exists, set "SNC_DIR" in "sncFile".
- if(!exist){ //There is not "SNC_DIR".
- exist = ExistFile(fname); // It searches current directory.
- if(!exist) return NO_SNC_FILE; // It does not create *.snc file.
- strcpy(sncFile, fname);
- } else strcat(sncFile, fname);
- //cout << "UpdateConstantFile() is called" << endl;
- int enough = 0, existSncFile = ExistFile(sncFile);
-
- if(existSncFile) enough = SetConstByFile(sncFile, (*pfunc),(*pfCalcFunc), ef);
- if(enough) return SNC_ENOUGH;
-
- /******** updating constant file **********/
- SDouble v;
- int format = v.CRLF| v.CONTINUE | v.INT_PUT;
- char buff[SNC_MAX_PATH+100];
- if(v.ShowMessage()){
- sprintf(buff, "%s \"%s\" file.\n", existSncFile ? "Updating" : "Creating", sncFile);
- v.ShowMessage(buff);
- }
- v = (*pfCalcFunc)(); // It evaluates constant.
-
- v.OutPutFile(sncFile, 1); // open file with overwrite
- sprintf(buff, "Total digits = %ld.\n", v.DFigures());
- v.FPuts(buff);
-
- v.Puts(10, 0, 5, format); // output
- v.OutPutFile(NULL); // close file
- (*pfunc)(&v, pfCalcFunc); // It sets constant.
-
- return SNC_UPDATE;
- }
sdfupdtc.cpp : last modifiled at 2017/07/17 14:52:20(1,737 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).